" ****************
" Script section *
" ****************

" Add source navigation on python core livraries

if has("python")
python << EOF
import os
import sys
import vim
for p in sys.path:
    if os.path.isdir(p):
        vim.command(r"set path+=%s" % (p.replace(" ", r"\ ")))

def pythonExec():
    buf= vim.current.buffer
    sys._stdout = sys.stdout
    exec('\n'.join(buf))

EOF
endif

" *********************
" OS specific section *
" *********************

if has("gui_gtk2")
    set guifont=Monospace\ 10
    let vimpath = "~/l30-environment/vim"
    let cfgfile = ".vimrc"
elseif has("gui_win32")
    set guifont=Consolas:h12
    let vimpath = "~/vimfiles"
    let cfgfile = "_vimrc"
end


" ****************
" Config section *
" ****************

"autocmd FileType python set omnifunc=pysmell#Complete
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType c set omnifunc=ccomplete#Complete
exec "autocmd BufNewFile,BufRead *.xml source ".vimpath."/ftplugin/xml.vim"

" AutoComplPop configuration
let g:AutoComplPop_NotEnableAtStartup = 0
let g:AutoComplPop_MappingDriven = 1

" Ropevim configuration
let ropevim_vim_completion=1
let ropevim_guess_project=1

" FuzzyFinder configuration
let g:fuzzy_roots = ['./dev/java/workspace', './dev/python/workspace', './l30-environment']
let g:fuzzy_ignore = "*.bak,*.pyc,*.py~,*.pdf,*.so,*.gif,*.jpg,*.flv,*.class,*.png,*/tools/*,*/docs/*" 
let g:fuzzy_ceiling = 50000
let g:fuzzy_enumerating_limit = 25

"set tags+=$HOME/.vim/tags/python.ctags
colorscheme metacosm
set anti
set textwidth=0
set tabstop=4
set softtabstop=4
set shiftwidth=4
"set foldmethod=indent
set encoding=utf-8
set expandtab
set backspace=indent,eol,start
set smarttab
set smartindent
set showmode
set showmatch       " Show matching brackets.
set autowrite       " Automatically save before commands like :next and :make
set ignorecase      " Do case insensitive matching
set incsearch       " Incremental search
set wmh=0           " set winminheight to 0
set ruler
set linebreak
set nocompatible
set guioptions-=T   " Turn toolbar off
set virtualedit=all
set cursorline      " Highlight current line
set smartcase       " Do smart case matching
syntax on

" *****************
" Mapping section *                    
" *****************

map <silent><C-Left> <C-T>
map <silent><C-Right> <C-]>
vmap <C-y> "+y
vmap <silent><C-s> :sort<CR>
nmap <C-s> :w<CR>
imap <silent><C-s> <ESC>:w<CR>a
imap <silent><C-Del> <ESC>dea
inoremap <C-k> <ESC>
nnoremap j gj
nnoremap k gk
nnoremap <space> za

nnoremap <silent><F2> :NERDTreeToggle<CR>
nnoremap <silent><F3> :FuzzyFinderTextMate<CR>
nnoremap <silent><F8> :TlistToggle<CR>
nmap <silent><F9> :call Bexec()<CR>
vmap <silent><F9> :call BexecVisual()<CR>
exec "nmap <F5> :source ~/".cfgfile."<CR>"

nmap <silent><C-n> :tabnew<CR>
nnoremap x :q<CR>
nnoremap X :q!<CR>

imap <silent><C-Space> <ESC>l:RopeCodeAssist<CR>
nmap <silent><C-Space> :RopeCodeAssist<CR>
nnoremap <silent>, :call RopeShowDoc()<CR>

map <C-J> <C-W>j<C-W>_
map <C-K> <C-W>k<C-W>_
